import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:jie_brother_study/http/WanAndroid.dart';
/// 状态共享，不推荐使用event_bus，推荐使用provider、getX等
void main() {
  WanAndroid.init();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Builder(
        builder: (context) {
          return Scaffold(
            body: Center(
              child: TextButton(
                  onPressed: () {
                    // WanAndroid().getBanner().then((value) {
                    //   var response = BaseResponse<List<BannerEntity>>.fromJson(
                    //       json.decode(value), (json) {
                    //     return (json as List)
                    //         .map((e) => BannerEntity.fromJson(e))
                    //         .toList();
                    //   });
                    //   // var response = BaseResponse.fromJson(json.decode(value), (json) => json.toString());
                    //   print(response.data?[0].title);
                    // });

                    Navigator.push(context, MaterialPageRoute(builder: (context) {
                      return Container(
                        color: Colors.white,
                        alignment: Alignment.center,
                        child: const Text('新页面'),
                      );
                    }));
                  },
                  child: const Text('点击我')),
            ),
          );
        }
      ),
    );
  }

  void test() async {
    var response = await Dio().get('https://www.wanandroid.com/banner/json');
    print(response.data.toString());
  }
}
